<template>
  <div class="modle infomation" v-show="show">
    <div class="tit"><b>公告</b></div>
    <p class="info">1.字数限制为45</p>
    <div class="content flex-btw">
      <img class="icon" src="../../../assets/images/info.png" />
      <!-- <input
        class="input"
        v-model="infomationInfo.content"
        type="textarea"
        :row="2"
        maxlength="45"
        placeholder="请输入……"
      /> -->
      <el-input
        v-model="infomationInfo.content"
        maxlength="45"
        type="textarea"
        :rows="2"
        placeholder="请输入……"
      >
      </el-input>
    </div>
    <div class="flex-center">
      <div class="submit flex-center" @click="submit()">保存</div>
    </div>
  </div>
</template>

<script>
import { apiUrl, objKeySort, Md5 } from "@/utils/public";
import { partnerNotice_save, partnerNotice_index } from "@/api/shop/shop";
export default {
  name: "infomation",
  props: ["show"],
  data() {
    return {
      infomationInfo: {
        content: "",
        type: 1,
      },
    };
  },
  created() {
    let params = Object.assign(
      {
        sign: Md5(
          objKeySort(Object.assign(apiUrl().name, { type: 1 })) +
            apiUrl().appsecret
        ),
      },
      apiUrl().name,
      { type: 1 }
    );
    partnerNotice_index(params).then((res) => {
      if (res.errcode == 0) {
        this.infomationInfo.content = res.data.content;
      } else {
        this.$message.error(res.errmsg);
      }
    });
  },
  methods: {
    submit() {
      let data = this.infomationInfo;
      this.listLoading = true;
      let params = Object.assign(
        {
          sign: Md5(
            objKeySort(Object.assign(apiUrl().name, data)) + apiUrl().appsecret
          ),
        },
        apiUrl().name,
        data
      );
      partnerNotice_save(params).then((res) => {
        this.listLoading = false;
        if (res.errcode == 0) {
          this.$message.success("保存成功");
        } else {
          this.$message.error(res.errmsg);
        }
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.infomation {
  width: 500px;
  .content {
    margin-top: 14px;
    background: #fff;
    padding: 12px 6px 12px 15px;
    .icon {
      width: 30px;
      height: 30px;
      margin-right: 10px;
    }
    .input {
      flex: 1;
      height: 72px;
      border: 1px solid #bcbec0;
      border-radius: 4px;
      padding: 0 15px;
    }
    .flex-btw {
      align-items: flex-start;
    }
  }
}
</style>